#! /usr/bin/python

# To change this template, choose Tools | Templates
# and open the template in the editor.

__author__ = "Ronald"
__date__ = "$05-06-2010 05:56:09 PM$"

from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *
from body import Body
from OpenGL.GL import glRotate
from numpy import *
# from OpenGL.GL import glScale

windowId = -1
WIDTH = 800
HEIGHT = 600

mybody = Body(0.5, [1, 2, 0])

def reshape():
    global WIDTH, HEIGHT
    glViewport(0, 0, WIDTH, HEIGTH)
    glMatrixMode(GL_PROJECTION)
    glLoadIdentity()
    gluPerspective(theta, w / h, near, far)
    gluLookAt(0, 0, DISTANCE, 0, 0, 0, 0, 1, 0)
    glMatrixMode(GL_MODELVIEW)
    glLoadIdentity()
    glTranslatef(0.0, 0.0, -5.0)

def display():
    glClear(GL_COLOR_BUFFER_BIT)
    glColor3f (0.0, 0.0, 1.0)
    # glLoadIdentity()                # clear the matrix

    mybody.draw()
    glFlush()

    glutSwapBuffers()

def main():
    global windowId
    global WIDTH, HEIGHT

    # Inicializa kit de herramientas GLUT
    glutInit()
    # Inicializa modo de display
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH)
    # Inicializa tamagno de ventana
    glutInitWindowSize(WIDTH, HEIGHT)
    # Inicializa posicion de ventana
    glutInitWindowPosition(0, 0)
    # Abre la ventana
    windowId = glutCreateWindow("Proyecto Robotv2 - Marcel & Ronald")
    # Registra display callback function
    glutDisplayFunc(display)

    # La funci'on cuando el programa este Idle.
    # En un videoJuego, 'este ser'ia el lugar donde actualizo posiciones, calculo puntajes, etc.
    glutIdleFunc(display)

    # set the reshape callback for the current window
    # cglutReshapeFunc(reshape)

    # enter GLUT event processing loop
    glutMainLoop()
    # set the coordinate system to projection matrix stack

    gluOrtho2D(-1, 1, -1, 1)
    glMatrixMode(GL_PROJECTION)
    glShadeModel (GL_FLAT)
main()